/*
 * Test the global iterators accessors:
 * * C++11 begin, end
 * * C++14 rbegin, rend
 * * C++17 size, empty, data
 * 
 * */
#include <cxxomfort/base.hpp>
#include <cxxomfort/array.hpp>
#include <cxxomfort/iterator.hpp>
//#include <cxxomfort/library/fixed_vector.hpp>
#include <cxxomfort/library/type_name.hpp>
#include <iostream>
#include <list>
#include <vector>
#include <ctime>
#include <cstdlib>

typedef unsigned Type;

int main () {
	using namespace std;
	using cxxomfort::library::typeid_demangle;
	cxxomfort::output_info(stdout); cout<< endl;
	
	srand(time(0));
	cout<< "C++11 accessors: "<< CXXO_COMPILER_SUPPORT_iterator_accessors_11<< " "<< CXXOMFORT_IMPLEMENTS_iterator_accessors_11<< endl;
	cout<< "C++14 accessors: "<< CXXO_COMPILER_SUPPORT_iterator_accessors_14<< " "<< CXXOMFORT_IMPLEMENTS_iterator_accessors_14<< endl;
	cout<< "C++17 accessors: "<< CXXO_COMPILER_SUPPORT_iterator_accessors_17<< " "<< CXXOMFORT_IMPLEMENTS_iterator_accessors_17<< endl;
	//cout<< "p1227 accessors: "<< CXXOMFORT_IMPLEMENTS_p1227r0<< endl;
	cout<< "ssize: "<< CXXOMFORT_IMPLEMENTS_ssize<< endl;
	
	list<Type> V(20);
	// check the C++11 global accessors
	generate (begin(V), end(V), rand);
	cout<< endl;
	
	// check the C++14 global accessors
	vector<Type> W(V.size());
	copy (cbegin(V), cend(V), rbegin(W));

	cout<< "V:\t";
	CXXO_FOREACH(Type x, V) {
		cout<< x<< " ";
	} cout<< endl;
	cout<< "W:\t";
	CXXO_FOREACH(Type x, W) {
		cout<< x<< " ";
	} cout<< endl;


#if 0
	// check the C++17 accessors
	cout<< "type of container: "<< typeid_demangle(typeid(V))<< endl;
	cout<< "size() : "<< V.size()<< endl;
	cout<< "type of size(): "<< typeid_demangle( typeid(V.size()) )<< endl;
	cout<< "std::size(V) : "<< size(V)<< endl;
	cout<< "type of std::size: "<< typeid_demangle( typeid(size(V)) )<< endl;
	cout<< "std::ssize(V) : "<< ssize(V)<< endl;
	cout<< "type of std::ssize: "<< typeid_demangle( typeid(ssize(V)) )<< endl;
	cout<< "std::empty(V) : "<< empty(V)<< endl;
	cout<< "type of std::empty: "<< typeid_demangle( typeid(empty(V)) )<< endl;
	//cout<< "std::data(V) : "<< (void*)data(V)<< endl;
	//cout<< "type of std::data: "<< typeid_demangle( typeid(data(V)) )<< endl;
#endif
	
}

